//
//  LWBottomView.m
//  1.28  weibo
//
//  Created by mac on 15/2/21.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "LWBottomView.h"
#import "LWstatuses.h"
@interface LWBottomView ()
/*******底部视图****************************/
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomViewConstant;
@property (weak, nonatomic) IBOutlet UIButton *retweetBtn;
@property (weak, nonatomic) IBOutlet UIButton *commonBtn;
@property (weak, nonatomic) IBOutlet UIButton *unLikeBtn;

@end

@implementation LWBottomView

- (void)setStatus:(LWstatuses *)status{

    _status = status;
    //3 设置底部视图
    [self setBtnwith:_status.reposts_count buttonName:self.retweetBtn titleName:@"转发"];
    [self setBtnwith:_status.comments_count buttonName:self.commonBtn titleName:@"评论"];
    [self setBtnwith:_status.attitudes_count buttonName:self.unLikeBtn titleName:@"赞"];
}
- (void)setBtnwith:(NSNumber *)count buttonName:(UIButton *)btn titleName:(NSString *)name{
    
    if (count.longLongValue > 0) {
        NSString *title = nil;
        if (count.longLongValue > 1000) {
            double number = count.longLongValue / 1000.0;
            title = [NSString stringWithFormat:@"%.1f万",number];
            title = [title stringByReplacingOccurrencesOfString:@".0" withString:@""];
            
        }else{
            title = [count description];
        }
        [btn setTitle:title forState:UIControlStateNormal];
    }else{
        [self.retweetBtn setTitle:name forState:UIControlStateNormal];
    }
}

@end
